package com.example.demo.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.demo.common.Result;
import com.example.demo.entity.Desk;
import com.example.demo.mapper.DeskMapper;
import com.example.demo.service.DeskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("mydeskcontroller")
public class MyDesk {
    @Autowired
    DeskService deskService;

    @PostMapping("/add")
    public Result<?> add(@RequestBody Desk desk) {
        if (StringUtils.isNotBlank(null)) {
            System.out.println(desk);
        }

        deskService.save(desk);
        return Result.success();
    }

    @PutMapping("/updateOne")
    public Result<?> updateOne(@RequestBody Desk desk) {
        if (StringUtils.isNotBlank(null)) {
            System.out.println(desk);
        }

        deskService.updateOne(desk);
        return Result.success();
    }

    @DeleteMapping("/deleteOne")
    public Result<?> deleteOne(@RequestBody Desk desk) {
        System.out.println(desk);

        deskService.deleteOne(desk);
        return Result.success();
    }


    @PostMapping("/findAll")
    public Result<?> findAll() {
        return Result.success(deskService.findAll());
    }
}
